// 首页界面
<template>
  <div class="music">
    <sv-header></sv-header>
    <div class="content">
      <div class="left">
        <player />
      </div>
      <div class="right">
        <keep-alive>
          <router-view />
        </keep-alive>
      </div>
    </div>
    <transition name="fade">
      <div class="footer" v-show="similarList.length > 0 ? true : false">
        <p class="title">相关歌曲</p>
        <slider :data="similarList" />
      </div>
    </transition>
  </div>
</template>

<script>
// @ is an alias to /src
import svHeader from '@/components/svHeader/index.vue';
import slider from '@/components/slider/index.vue';
import player from '@/components/player/index.vue';
import { mapActions, mapGetters } from 'vuex';
import { getPlaylistDetail } from '@/api';
import { defaultPlayListID } from '@/config';

export default {
  name: 'music',
  components: {
    svHeader,
    slider,
    player,
  },
  computed: {
    ...mapGetters(['similarList']),
  },
  methods: {
    ...mapActions(['setPlayList']),
  },
  created() {
    getPlaylistDetail(defaultPlayListID).then((playlist) => {
      const list = playlist.tracks.slice(0, 100);
      this.setPlayList({ list });
    });
  },
};
</script>
<style lang="scss" scoped>
.music {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  .content {
    width: 100%;
    flex: 1;
    display: flex;
    overflow: hidden;
    .left {
      width: 300px;
      padding-right: 5vw;
    }
    .right {
      flex: 1;
    }
  }
  .content,
  .footer {
    box-sizing: border-box;
    display: flex;
    padding: 2vh 5vw;
    width: 100vw;
  }
  .footer {
    padding: 0 5vw;
    padding-bottom: 10px;
    display: flex;
    flex-direction: column;
    .title {
      line-height: 40px;
      color: #ffffff;
      font-size: 18px;
    }
  }
}
</style>
